package com.wtwd.campus.receiver;

import com.wtwd.campus.entity.MqStepAndBatteryMessage;
import com.wtwd.campus.service.InjectFeignService;

public class ActiveGetStepReceiver implements Receiver {

    @Override
    public String parseMessage(String data) {
        //*WT,866248053277321,V4,GETSTEP,161115,0,16,060721,FDFFFFFF
        String[] split = data.split(",");
        String imei = split[1];
        String messageType = split[2];
        String type = split[3];
        String commandNumber = split[4];
        String stepNum = split[5];//步数
        String battery = split[6];  // 电量
        String date = split[7];//日月年
        String deviceStatus = split[8];
        MqStepAndBatteryMessage mqStepAndBatteryMessage = new MqStepAndBatteryMessage();
        mqStepAndBatteryMessage.setBattery(Integer.parseInt(battery));
        mqStepAndBatteryMessage.setCommandNumber(commandNumber);
        mqStepAndBatteryMessage.setImei(imei);
        mqStepAndBatteryMessage.setDeviceDate(date);
        mqStepAndBatteryMessage.setStepNum(Integer.parseInt(stepNum));
        mqStepAndBatteryMessage.setDeviceTime(commandNumber);
        mqStepAndBatteryMessage.setDeviceStatus(deviceStatus);
        InjectFeignService.getIrmFeignClientService().activeGetStepMessage(mqStepAndBatteryMessage);
        return imei;
    }
}
